GPG AES-256 File Encryption
Description
The encrypt_file_gpg_aes256
function encrypts a file using GPG with AES-256 encryption, supporting both Windows and Linux platforms. This is useful for securely encrypting sensitive files using a passphrase.
Function Signature:
def encrypt_file_gpg_aes256(input_file_path: str, password: str) -> str:
Parameters
- input_file_path (str): Full path to the file that you want to encrypt.
- password (str): The password used for encryption.
Returns
- str: The full path to the encrypted file with the
.gpg
extension.
Example Usage
encrypted_file = encrypt_file_gpg_aes256("/path/to/file.txt", "your_password")
print(f"Encrypted file saved to: {encrypted_file}")
Notes
- The encryption uses AES-256 encryption algorithm with GPG.
- The
.gpg
extension will be added to the encrypted file. - The function raises an error if the input file is not found or if the encryption fails.
Error Handling
- FileNotFoundError: Raised if the input file does not exist.
- RuntimeError: Raised if the encryption fails or if the encrypted file is not created.